#!/bin/bash
# 检查build-essential包是否已安装
dpkg -s build-essential > /dev/null 2>&1
if [ $? -eq 0 ]; then
    echo "build-essential已安装"
else
    echo "build-essential尚未安装，现在安装..."
    # 使用apt-get安装build-essential
    apt-get update
    apt-get install -y build-essential
fi
#检查 cmake 是否已安装
if ! command -v cmake >/dev/null 2>&1; then
    echo "cmake 未安装正在尝试安装"
    apt-get install -y cmake
fi
# 检查 pkg-config 是否已安装
if ! command -v pkg-config >/dev/null 2>&1; then
    echo "pkg-config 未安装正在尝试安装"
    apt-get install -y pkg-config
fi
# 安装 git 工具
if ! command -v git >/dev/null 2>&1; then
    echo "git 未安装正在尝试安装"
    apt-get install -y git
fi

#检查 cmake 是否已安装
if ! command -v cmake >/dev/null 2>&1; then
    echo "cmake 未安装正在尝试安装"
    apt-get install -y cmake
fi
#检查 zlib1g-dev 是否已安装
if ! dpkg -l | grep -q "zlib1g-dev"; then
    echo "zlib1g-dev 未安装正在尝试安装"
    apt-get install -y zlib1g-dev
fi

# 检查nasm是否安装
if ! dpkg -l | grep -q "nasm"; then
    echo "nasm 未安装正在尝试安装"
    apt-get install -y nasm
fi

# 检查automake是否安装
if ! dpkg -l | grep -q "automake"; then
    echo "automake 未安装正在尝试安装"
    apt-get install -y automake
fi

# 检查autoconf是否安装
if ! dpkg -l | grep -q "autoconf"; then
    echo "autoconf 未安装正在尝试安装"
    apt-get install -y autoconf
fi

# 检查libtool是否安装
if ! dpkg -l | grep -q "libtool"; then
     echo "libtool 未安装正在尝试安装"
     # apt-get install -y libtool
fi
# 检查libtool是否安装
if ! which libtool > /dev/null; then
    echo "libtool is installed."
else
    echo "libtool is not installed."
fi


if pkg-config --exists x265; then
    echo "x265 found"
    # 设置环境变量或执行其他操作
else
    echo "x265 not found"
    # 处理x265不存在的情况
fi

if ! command -v libtool > /dev/null; then
    echo "libtool 未安装，请先安装 libtool"
fi












